package com.jiangjiang.eshop.common.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * @ClassName SpringApplicationContext
 * @Description Spring 容器组件
 * @Author jhw
 * @Date 2021/7/9 12:26
 * @Version 1.0
 **/
@Component
public class SpringApplicationContext {

    @Autowired
    private ApplicationContext context;


    /**
     * 获取bean
     * @param clazz bean类型
     * @return bean实例
     */
    public <T> T getBean(Class<? extends T> clazz) {
        return context.getBean(clazz);
    }

}
